package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Jobrecord;
import com.zjsd.sqeybusiness.service.IJobrecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 当天工作内容
Controller
 *
 * @author Zheng
 * @date 2022-06-23
 */
@RestController
@RequestMapping("/sqeybusiness/jobrecord")
public class JobrecordController extends BaseController
{
    @Autowired
    private IJobrecordService jobrecordService;

    /**
     * 查询当天工作内容
列表
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jobrecord jobrecord)
    {
        startPage();
        List<Jobrecord> list = jobrecordService.selectJobrecordList(jobrecord);
        return getDataTable(list);
    }

    /**
     * 导出当天工作内容
列表
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobrecord:export')")
    //@Log(title = "当天工作内容 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Jobrecord jobrecord)
    {
        List<Jobrecord> list = jobrecordService.selectJobrecordList(jobrecord);
        ExcelUtil<Jobrecord> util = new ExcelUtil<Jobrecord>(Jobrecord.class);
        return util.exportExcel(list, "jobrecord");
    }

    /**
     * 获取当天工作内容
详细信息
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobrecord:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(jobrecordService.selectJobrecordById(recordid));
    }

    /**
     * 新增当天工作内容

     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobrecord:add')")
    //@Log(title = "当天工作内容 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jobrecord jobrecord)
    {
        return toAjax(jobrecordService.insertJobrecord(jobrecord));
    }

    /**
     * 修改当天工作内容

     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobrecord:edit')")
    //@Log(title = "当天工作内容 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jobrecord jobrecord)
    {
        return toAjax(jobrecordService.updateJobrecord(jobrecord));
    }

    /**
     * 删除当天工作内容

     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobrecord:remove')")
    //@Log(title = "当天工作内容 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(jobrecordService.deleteJobrecordByIds(recordids));
    }
}
